package com.zxpt.quetion.service.impl;

import com.zxpt.quetion.pojovo.QuestionMouldVo;
import com.zxpt.quetion.service.IQuestionMouldService;
import com.zxpt.quetion.mappervo.QuestionMouldMapperVo;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.PageHelper;
import java.util.Map;
import java.util.List;
import javax.annotation.Resource;
import  com.zxpt.quetion.utils.Query;
import  com.zxpt.quetion.utils.CreateQueryConditionUtil;
import  com.zxpt.quetion.utils.SqlUtil;

/**
* 所在包：com.zxpt.quetion.service.impl.QuestionMouldServiceImpl
* 文件名：QuestionMouldServiceImpl
* 版权：稻草人.
* 描述：
* 修改人：huizi
* 修改时间：
*/
@Service
@Transactional
@Slf4j
public class QuestionMouldServiceImpl implements IQuestionMouldService {

    @Resource
    private QuestionMouldMapperVo questionMouldMapperVo;

    @Override
    public PageInfo<QuestionMouldVo> getPage (Map<String, Object> queryMap, Integer page, Integer rows) {
        Query query = CreateQueryConditionUtil.createCondition(queryMap);
        PageHelper.startPage(page, rows);
        List<QuestionMouldVo> list = questionMouldMapperVo.getPage(query.getSql(), queryMap);
        PageInfo<QuestionMouldVo> pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public QuestionMouldVo getById(String id) {
        QuestionMouldVo questionMouldVo = questionMouldMapperVo.getById(id);
        return questionMouldVo;
    }

    @Override
    public String add(QuestionMouldVo questionMouldVo) {
        SqlUtil<QuestionMouldVo> sqlUtil = new SqlUtil<>();
        String sql = sqlUtil.createInsertSql(QuestionMouldVo.class, questionMouldVo);
        questionMouldMapperVo.insertSelective(questionMouldVo, sql);
        return questionMouldVo.getId();
    }

    @Override
    public void update(QuestionMouldVo questionMouldVo) {
        SqlUtil<QuestionMouldVo> sqlUtil = new SqlUtil<>();
        String sql = sqlUtil.createUpdateSelectiveSql(QuestionMouldVo.class, questionMouldVo);
        questionMouldMapperVo.updateSelective(questionMouldVo, sql);
    }

    @Override
    public void updateAbsolute(QuestionMouldVo questionMouldVo) {
        SqlUtil<QuestionMouldVo> sqlUtil = new SqlUtil<>();
        String sql = sqlUtil.createUpdateAbsoluteSql(QuestionMouldVo.class);
        questionMouldMapperVo.updateAbsolute(questionMouldVo, sql);
    }

    @Override
    public void delById(String id) {
        questionMouldMapperVo.delById(id);
    }
}
